home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / ear / mui23dev.lha / MUI / Developer / Modula / Demo / MuiTest.mod < prev   
Text File  |  1994-06-04  |  7KB  |  207 lines

  1. MODULE MuiTest;
  2.  
  3. (*$ LargeVars:=FALSE *)
  4.  
  5. (*
  6. ** This is just a little demo Prg. to show how to use MUI in Modula
  7. ** It has no functions, it just looks good (who cares.... ;-)
  8. ** Please note : There was a little bugfix in this version.
  9. **               Look where the WindowID gets defined - you have
  10. **               to write MakeID("....") instead of ADR("....")
  11. **               then MUI will store your window position!!
  12. **
  13. ** Version : 13.10.1993
  14. *)
  15.  
  16. IMPORT MD:MuiD;
  17. IMPORT ML:MuiL;
  18. IMPORT MM:MuiMacros;
  19. FROM   MuiMacros IMPORT set,get,MakeID;
  20. FROM   MuiSupport IMPORT DOMethod, DoMethod, APTR, fail;
  21. FROM   SYSTEM IMPORT TAG, ADR, LONGSET, CAST;
  22. FROM   ExecL IMPORT Wait;
  23. FROM   UtilityD IMPORT tagEnd;
  24.  
  25. TYPE
  26.     ShortString = ARRAY[0..3] OF CHAR;
  27.  
  28. CONST
  29.     True  = 1;      (* These are for the set-Macro *)
  30.     False = 0;      (* because set excepts just LONGINT as argument *)
  31.     
  32.     IDbut1= 1;      (* The IDs for the Buttons *)
  33.     IDbut2= 2;
  34.     IDbut3= 3;
  35.     IDbut4= 4;
  36.     IDbut5= 5;
  37.     IDbut6= 6;
  38.  
  39. VAR app,window,bt1,bt2,bt3,bt4,bt5,bt6,Dirs  : APTR;
  40.     signals                                  : LONGSET;
  41.     running                                  : BOOLEAN;
  42.     msg                                      : LONGINT;
  43.     buffer                                   : ARRAY[0..30] OF LONGINT;
  44.     buffer1                                  : ARRAY[0..30] OF LONGINT;
  45.     buffer2                                  : ARRAY[0..30] OF LONGINT;
  46.     buffer3                                  : ARRAY[0..30] OF LONGINT;
  47.  
  48. BEGIN
  49.  
  50.     running := TRUE;
  51.  
  52.     (* Set up the buttons *)
  53.  
  54.     bt1 := MM.Simplebutton("Button 1");
  55.     bt2 := MM.Keybutton("Button 2",'u');
  56.     bt3 := MM.Keybutton("Button 3",'t');
  57.     bt4 := MM.Keybutton("Button 4",'o');
  58.     bt5 := MM.Keybutton("Button 5",'n');
  59.     bt6 := MM.Keybutton("Cancel",'c');
  60.  
  61.     (* Set up the Volumelist *)
  62.  
  63.     Dirs:= MM.ListviewObject(TAG(buffer1,
  64.                 MD.maListviewList,  MM.VolumelistObject(TAG(buffer2,
  65.                                         MD.maFrame,         MD.mvFrameInputList,
  66.                                         MD.maFrameTitle,    ADR("Magic Volumes"),
  67.                                         MD.maListFormat,    ADR("COL=0"),
  68.                                         tagEnd)),
  69.                 tagEnd));
  70.  
  71.     (* Set up the window *)
  72.  
  73.     window := MM.WindowObject(TAG(buffer,
  74.                     MD.maWindowTitle   , ADR("MUI-Test :-)"),
  75.                     MD.maWindowID      , MakeID("MAIN"),
  76.  
  77.                     MM.WindowContents,
  78.  
  79.                         (* Create an array of Buttons *)
  80.  
  81.                         MM.VGroup(TAG(buffer3,
  82.                             MM.Child, MM.HGroup(TAG(buffer1,
  83.                                     MD.maFrame,         MD.mvFrameGroup,
  84.                                     MD.maFrameTitle,    ADR("Magic Buttons"),
  85.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  86.                                             MM.Child, bt1,
  87.                                             MM.Child, bt2,
  88.                                             MM.Child, bt3,
  89.                                             tagEnd)),
  90.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  91.                                             MM.Child, bt4,
  92.                                             MM.Child, bt5,
  93.                                             MM.Child, bt6, (* cancel *)
  94.                                             tagEnd)),
  95.                                     tagEnd)),
  96.  
  97.                             (* Put the Volumelist below them *)
  98.  
  99.                             MM.Child, Dirs,
  100.                             tagEnd)),
  101.                 tagEnd));
  102.  
  103.     (* set up the application object *)
  104.  
  105.     app:=MM.ApplicationObject(TAG(buffer,
  106.                     MD.maApplicationTitle      , ADR("MUITest"),
  107.                     MD.maApplicationVersion    , ADR("V1.0ß"),
  108.                     MD.maApplicationCopyright  , ADR("©1993 by Christian Scholz"),
  109.                     MD.maApplicationAuthor     , ADR("Tochkopf"),
  110.                     MD.maApplicationDescription, ADR("Test the MUI-Magic :-)"),
  111.                     MD.maApplicationBase       , ADR("MUITest"),
  112.  
  113.                     MM.SubWindow, window,
  114.  
  115.             tagEnd));
  116.  
  117.     IF app=NIL THEN fail(app, "failed to create Application !!"); END;
  118.  
  119. (* Set up the notification *)
  120.  
  121.             DoMethod(window,TAG(buffer,
  122.                         MD.mmNotify,MD.maWindowCloseRequest,TRUE,
  123.                         app,2,MD.mmApplicationReturnID,IDbut6
  124.                         ));
  125.  
  126.             DoMethod(bt1,TAG(buffer,
  127.                         MD.mmNotify,MD.maPressed,FALSE,
  128.                         app,2,MD.mmApplicationReturnID,IDbut1
  129.                         ));
  130.  
  131.             DoMethod(bt2,TAG(buffer,
  132.                         MD.mmNotify,MD.maPressed,FALSE,
  133.                         app,2,MD.mmApplicationReturnID,IDbut2
  134.                         ));
  135.  
  136.             DoMethod(bt3,TAG(buffer,
  137.                         MD.mmNotify,MD.maPressed,FALSE,
  138.                         app,2,MD.mmApplicationReturnID,IDbut3
  139.                         ));
  140.  
  141.             DoMethod(bt4,TAG(buffer,
  142.                         MD.mmNotify,MD.maPressed,FALSE,
  143.                         app,2,MD.mmApplicationReturnID,IDbut4
  144.                         ));
  145.  
  146.             DoMethod(bt5,TAG(buffer,
  147.                         MD.mmNotify,MD.maPressed,FALSE,
  148.                         app,2,MD.mmApplicationReturnID,IDbut5
  149.                         ));
  150.  
  151.             DoMethod(bt6,TAG(buffer,
  152.                         MD.mmNotify,MD.maPressed,FALSE,
  153.                         app,2,MD.mmApplicationReturnID,IDbut6
  154.                         ));
  155.  
  156. (* Cycle Chain for Keyboard *)
  157.  
  158.             DoMethod(window,TAG(buffer,
  159.                         MD.mmWindowSetCycleChain,
  160.                         bt1, bt2, bt3, bt4, bt5, bt6, Dirs, 0
  161.                         ));
  162.  
  163. (* Main Loop *)
  164.  
  165.             (* Open the window and set first active object
  166.                Here is also shown, how to use True and False in set *)
  167.  
  168.             set(window,MD.maWindowOpen, True);
  169.             set(window,MD.maWindowActiveObject, Dirs);
  170.  
  171.             (* Event Loop *)
  172.  
  173.             WHILE running DO
  174.  
  175.                         CASE DOMethod(app, TAG(buffer,
  176.                                MD.mmApplicationInput, ADR(signals))) OF
  177.  
  178.                         |   MD.mvApplicationReturnIDQuit, IDbut6:
  179.                                     running:=FALSE;
  180.                         |   IDbut1,IDbut2,IDbut3,IDbut4, IDbut5:
  181.                                     fail(app, "Application failed of no reason");
  182.                         ELSE
  183.  
  184.                         END;
  185.  
  186.  
  187.                         IF running AND (signals <> LONGSET{} ) THEN signals:=Wait(signals);
  188.                                                    END;
  189.             END; (* While *)
  190.  
  191.             (* Close window *)
  192.  
  193.             set(window,MD.maWindowOpen, False);
  194.  
  195. (* Shut up *)
  196.  
  197.         fail(app,"");
  198.  
  199. END MuiTest.
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.